/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.creature.plant.plugin;

import java.awt.Image;
import model.creature.plant.AOEHealerPlant;
import model.game.GameInterface;
import model.item.Item;
import model.map.cell.PlantableCell;
import model.utility.ImageUtility;

/**
 * Trees that heals nearby crystals and plants.
 *
 * All creatures within 2 manhattan distance are healed each turn.
 * Crystals within 4 manhattan distance are healed.
 *
 * Grows full in 3 days. Dies in 12 days.
 *
 * Can be harvested and the herb disappears
 */
public class Herb extends AOEHealerPlant {

  public Herb (GameInterface game, PlantableCell cell) {
    super(game, cell);
  }

  @Override
  protected String getFruitName() {
    return "Medicinal Herb";
  }

  @Override
  protected int timeToMature() {
    return 1;
  }

  @Override
  protected int timeToDie() {
    return 1000000000;
  }

  @Override
  protected int timeToHarvest(int amount) {
    return 2;
  }

  @Override
  protected int getHPAtCurrentLevel() {
    return 25;
  }

  @Override
  public boolean canUpgrade() {
    if (getLevel() < 5) return true;
    return false;
  }

  @Override
  public int getUpgradeCost() {
    return getLevel() * getLevel() * 50 + 75;
  }

  @Override
  public Image getImage() {
    if (is_seed_) {
      return ImageUtility.loadImage("resources/pictures/plants/herb/seed.png");
    } else if (isHarvestable()) {
      return ImageUtility.loadImage("resources/pictures/plants/herb/harvestable.png");
    } else {
      return ImageUtility.loadImage("resources/pictures/plants/herb/mature.png");
    }
  }

  @Override
  public String getName() {
    return "Herb";
  }

  @Override
  public String getSeason() {
    return game_.getGameTime().getCurrentSeason().getName();
  }

  @Override
  public String getDescription() {
    return "Herbs that heals plants with maximum"
            + " distance " + getRadius() + " and crystlas with max"
            + " distance " + getCrystalRadius() + " during the day. "
            + "Can be upgraded to"
            + " increase its healing power. Can be harvested"
            + "and sold for a small price. Grows in summer. Will not die.";
  }

  @Override
  public int getRadius() {
    return 2;
  }

  @Override
  public int getHealCount()  {
    return 100;
  }

  @Override
  public int getHealPower() {
    return 4 + 2 * getLevel();
  }

  @Override
  public int getCrystalRadius() {
    return 4;
  }

  @Override
  public Item harvest() {
    assert isHarvestable();
    Item harvest_result =
            game_.getItemManager().constructItemFromName(getFruitName());
    game_.getCreatures().getPlants().removePlant(this);
    return harvest_result;
  }

}
